clear;

% This function will demo the creation of a 2D Gaussian filter from 2 1-D filters using the outer product
xstdsToShow=3
xtotalFilterSamples=31
[g_x,x]=createGaussianFilter(xstdsToShow,xtotalFilterSamples);


ystdsToShow=1
ytotalFilterSamples=21
[g_y,y]=createGaussianFilter(ystdsToShow,ytotalFilterSamples);

g2d=g_x*g_y';

figure
plot(x,g_x)
hold on
xstdPlot=[-xstdsToShow:xstdsToShow];
plot(xstdPlot,zeros(size(xstdPlot)),'og')
title(['Gaussian filter that is ' num2str(xtotalFilterSamples) ' samples long.'])
xlabel('std')
ylabel('coefficient value')

figure
plot(y,g_y)
hold on
ystdPlot=[-ystdsToShow:ystdsToShow];
plot(ystdPlot,zeros(size(ystdPlot)),'og')
title(['Gaussian filter that is ' num2str(ytotalFilterSamples) ' samples long.'])
xlabel('std')
ylabel('coefficient value')


figure;
surf(g2d)
title('2D Gaussian filter')
xlabel('sample number')
ylabel('sample number')
zlabel('coefficient value')

figure;
imagesc(g2d.')
title('Seperable 2D Gaussian filter')
xlabel('sample number')
ylabel('sample number')
colorbar

g2dRotate=imrotate(g2d, 45,[],'crop',0);

figure;
imagesc(g2dRotate.')
title('Nonseperable 2D Gaussian filter')
xlabel('sample number')
ylabel('sample number')
colorbar

